# -*- coding:utf-8 -*-
import csv


def down_file(head, data):
    """ head 是表头 例如 姓名 性别 地址
        data 数据 [[africle, 男, 河南], [kobe, 男, USA]]
    """
    csvfile = open('result.csv', 'wb')
    writer = csv.writer(csvfile)
    head = [item.encode("utf8") for item in head]
    writer.writerow(head)
    for sub_data in data:
        sub_data = [item.encode("utf8") for item in sub_data]
        writer.writerow(sub_data)       # 也可以直接writer.writerows(data) 但先把data里面的数据全部encode("utf8")
    csvfile.close()


def read_file():
    csvfile = open('test.csv', 'rb')
    reader = csv.reader(csvfile)
    for line in reader:
        print line

    csvfile.close()




















